﻿// JScript 文件
window["MzBrowser"] = {}; (function() {
    if (MzBrowser.platform) return;
    var ua = window.navigator.userAgent;
    MzBrowser.platform = window.navigator.platform;

    MzBrowser.firefox = ua.indexOf("Firefox") > 0;
    MzBrowser.opera = typeof (window.opera) == "object";
    MzBrowser.ie = !MzBrowser.opera && ua.indexOf("MSIE") > 0;
    MzBrowser.mozilla = window.navigator.product == "Gecko";
    MzBrowser.netscape = window.navigator.vendor == "Netscape";
    MzBrowser.safari = ua.indexOf("Safari") > -1;

    if (MzBrowser.firefox) var re = /Firefox(\s|\/)(\d+(\.\d+)?)/;
    else if (MzBrowser.ie) var re = /MSIE( )(\d+(\.\d+)?)/;
    else if (MzBrowser.opera) var re = /Opera(\s|\/)(\d+(\.\d+)?)/;
    else if (MzBrowser.netscape) var re = /Netscape(\s|\/)(\d+(\.\d+)?)/;
    else if (MzBrowser.safari) var re = /Version(\/)(\d+(\.\d+)?)/;
    else if (MzBrowser.mozilla) var re = /rv(\:)(\d+(\.\d+)?)/;

    if ("undefined" != typeof (re) && re.test(ua))
        MzBrowser.version = parseFloat(RegExp.$2);
})();

function dochange() {
    var membertype = document.getElementById("ctl00_ContentPlaceHolder1_xytype");
    var yx = document.getElementById("yx1");
    var yx2 = document.getElementById("yx2");
    var zy = document.getElementById("zy");
    var yxspan = document.getElementById("yxspan");


    if (membertype.value == "4") {
        zy.innerHTML = "部门：";
        yxspan.innerHTML = "";

        if (MzBrowser.firefox) {
            if (MzBrowser.version == 3) {
                colleges.innerHTML = "<option>教职工</option>";
            }
        }
        if (MzBrowser.ie) {
            if (MzBrowser.version == 6) {
                yx.style.display = "none";
                yx2.style.display = "none";
            }
        }

    }
    if (membertype.value == "5") {
        zy.innerHTML = "部门：";
        yxspan.innerHTML = "";

        if (MzBrowser.firefox) {
            if (MzBrowser.version == 3) {
                yx.style.display = "none";
                yx2.style.display = "none";
            }
        }
        if (MzBrowser.ie) {
            if (MzBrowser.version == 6) {
                yx.style.display = "none";
                yx2.style.display = "none";
            }
        }

    }
    if (membertype.value == "1" || membertype.value == "2" || membertype.value == "3" || membertype.value == "0") {
        zy.innerHTML = "专业：";
        yxspan.innerHTML = "*";

        if (MzBrowser.firefox) {
            if (MzBrowser.version == 3) {
                yx.style.display = "block";
                yx2.style.display = "block";
            }
        }
        if (MzBrowser.ie) {
            if (MzBrowser.version == 6) {
                yx.style.display = "block";
                yx2.style.display = "block";
            }
        }

    }

}

function doCheck() {
    var name1 = document.getElementById("ctl00_ContentPlaceHolder1_TBName");
    var birthday = document.getElementById("ctl00_ContentPlaceHolder1_TBBothDate");
    var username = document.getElementById("ctl00_ContentPlaceHolder1_TBUserName");
    var password = document.getElementById("ctl00_ContentPlaceHolder1_TBPassword");
    var email = document.getElementById("ctl00_ContentPlaceHolder1_Email");
    var address = document.getElementById("ctl00_ContentPlaceHolder1_TBAddress");
    var validpwd = document.getElementById("ctl00_ContentPlaceHolder1_TBValidPassword");
    var colleges = document.getElementById("ctl00_ContentPlaceHolder1_Colleges");
    var major = document.getElementById("ctl00_ContentPlaceHolder1_A_zy");
    var rxtime = document.getElementById("ctl00_ContentPlaceHolder1_rxtime");
   //var bytime = document.getElementById("ctl00_ContentPlaceHolder1_bytime");
    var membertype = document.getElementById("ctl00_ContentPlaceHolder1_xytype");
    //var yx = document.getElementById("yx1");
    //var yx2 = document.getElementById("yx2");
    //var zy = document.getElementById("zy");
    //var yxspan = document.getElementById("yxspan");

    var jiebie = document.getElementById("ctl00_ContentPlaceHolder1_TBJieBie");

    
    if (name1.value == "") 
    {
        alert("姓名不能为空！")
        name1.focus();
        return false;
    }
    if (membertype.value == "0") 
    {
        alert("校友类型不能为空！")
        membertype.focus();
        return false;
    }
    if (jiebie.value == "") 
    {
        alert("届别不能为空！")
        jiebie.focus();
        return false;
    }else{
         re = new RegExp("^[0-9]{4}$");
        if (jiebie.value.match(re) == null) {
            alert("届别格式请参照样例填写年份！");
            username.focus();
            return false;
        }
    
    
    }
//    if (birthday.value != "") 
//    {
//        if (birthday.value.match(re) == null) 
//        {
//            alert("出生日期格式应为1972-04-20！");
//            birthday.focus();
//            return false;
//        }
    //    }
    if (colleges.value == "0") 
    {
        alert("院系不能为空！")
        colleges.focus();
        return false;
    }
    if (major.value == "0") 
    {
            alert("专业不能为空！")
            major.focus();
            return false;
    }
    if (username.value == "") {
        alert("用户名不能为空！")
        username.focus();
        return false;
    }
    else {
        re = new RegExp("^[0-9a-zA-Z_]{6,16}$");
        if (username.value.match(re) == null) {
            alert("用户名应为6到16位字母数字或下划线的组合！");
            username.focus();
            return false;
        }
    }
    if (password.value == "") 
    {
        alert("密码不能为空！")
        password.focus();
        return false;
    }
    else 
    {
        re = new RegExp("^[0-9a-zA-Z]{6,16}$");
        if (password.value.match(re) == null) 
        {
            alert("密码应为6到16位字母数字的组合！");
            password.focus();
            return false;
        }
    }
    if (validpwd.value == "") 
    {
        alert("验证密码不能为空！")
        validpwd.focus();
        return false;
    }
    if (password.value != validpwd.value) 
    {
        alert("两次输入密码不相符！")
        validpwd.focus();
        return false;
    }
    if (email.value == "") 
    {
        alert("邮箱不能为空！")
        email.focus();
        return false;
    }
    else 
    {
        re = new RegExp("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
        if (email.value.match(re) == null) 
        {
            alert("邮箱格式不正确！");
            email.focus();
            return false;
        }
    }
    if (address.value == "") {
    
        alert("通信地址不能为空！")
        address.focus();
        return false;
    }
    return true;
}
